/* $Id: rpmeval.c 5 2008-05-27 10:41:12Z lafriks $ */

#include <rpm/rpmlib.h>
#include <rpm/rpmmacro.h>

int main(int argc, char **argv)
{
    int rc;
    char *results;
    if (argc != 3) {
        fprintf(stdout, "Not enough argument: %d\n", argc);
        return 1;
    }
    if (rc = rpmReadConfigFiles(NULL, NULL)) {
        fprintf(stderr, "Cannot load configuration\n");
        return rc;
    }
    if (rc = rpmLoadMacroFile(rpmGlobalMacroContext, argv[1])) {
        fprintf(stderr, "Cannot read %s\n", argv[1]);
        return rc;
    }
    results = rpmExpand(argv[2], NULL);
    fprintf(stdout, "%s\n", results);
    return 0;
}
